// 购物车界面

const app = getApp()
const db = wx.cloud.database()
const _ = db.command

Page({

  /**
   * 页面的初始数据
   */
  data: {
    goodsObjects:[],
    buyCarId: [],
    id: "2"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getGoods()
  },


  //获取购物车商品
  getGoods(){
    var that = this
    app.appGetOpenId().then(res=>{
      db.collection('mine').where({
        _openid: res
      }).get().then(res=>{
        that.setData({
          buyCarId: res.data[0].buyCar
        })
        db.collection("goods").where({
          _id: _.in(that.data.buyCarId)
        }).get().then(res=>{
          that.setData({
            goodsObjects : res.data,
          })
        })
      })
    })
  },

})